package com.restaurant.application.minifacade.data;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;

public class ConsumptionBO implements PickableBean {

    public static final String FN_CONTENT = "content";
    public static final String FN_PAYTIME = "payTime";
    public static final String FN_INTEGRAL = "integral";
    public static final String FN_MONEY = "money";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_CONTENT,
            FN_PAYTIME,
            FN_INTEGRAL,
            FN_MONEY);

    private String content;
    private Long payTime;
    private Long integral;
    private Double money;

    public ConsumptionBO(String content, Long payTime, Long integral, Double money) {
        setContent(content);
        setPayTime(payTime);
        setIntegral(integral);
        setMoney(money);
    }

    public ConsumptionBO() {
    }

    public ConsumptionBO duplicate() {
        ConsumptionBO result = new ConsumptionBO();
        result.content = this.content;
        result.payTime = this.payTime;
        result.integral = this.integral;
        result.money = this.money;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public String getContent() {
        return content;
    }

    public void setContent(String value) {
        this.content = value;
    }

    public ConsumptionBO withContent(String value) {
        setContent(value);
        return this;
    }

    public ConsumptionBO withContent(String value, String defaultValue) {
        setContent(value == null ? defaultValue : value);
        return this;
    }

    public Long getPayTime() {
        return payTime;
    }

    public void setPayTime(Long value) {
        this.payTime = value;
    }

    public ConsumptionBO withPayTime(Long value) {
        setPayTime(value);
        return this;
    }

    public ConsumptionBO withPayTime(Long value, Long defaultValue) {
        setPayTime(value == null ? defaultValue : value);
        return this;
    }

    public Long getIntegral() {
        return integral;
    }

    public void setIntegral(Long value) {
        this.integral = value;
    }

    public ConsumptionBO withIntegral(Long value) {
        setIntegral(value);
        return this;
    }

    public ConsumptionBO withIntegral(Long value, Long defaultValue) {
        setIntegral(value == null ? defaultValue : value);
        return this;
    }

    public Double getMoney() {
        return money;
    }

    public void setMoney(Double value) {
        this.money = value;
    }

    public ConsumptionBO withMoney(Double value) {
        setMoney(value);
        return this;
    }

    public ConsumptionBO withMoney(Double value, Double defaultValue) {
        setMoney(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "content":
                return getContent();
            case "payTime":
                return getPayTime();
            case "integral":
                return getIntegral();
            case "money":
                return getMoney();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof ConsumptionBO)) return false;
        return signature().equals(((ConsumptionBO) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean ConsumptionBO has no signature defined, no hash code or equals possible.");
    }
}
